<extend name="layout/main" />

<block name="HEADER">
	<style type="text/css">
		.layui-layer-page .layui-layer-content{
			overflow: initial;
		}
		#grid .layui-table-view .layui-table td .layui-table-cell{
			height: 36px;
		    line-height: 36px;
		}
		#grid .layui-btn+.layui-btn {
		    margin-left: 0;
		}
		.file-img {
		    height: 100%;
		    background-position: left;
		    background-size: 100% 85%;
		    background-repeat: no-repeat;
		    cursor: pointer;
		}
	</style>
</block>

<block name="CONTENT">
	<div class="wrapper">
		<div class="panel-heading">
			<control:search id="searchs" />
		</div>
		<div class="content">
			<control:grid id="grid" padding="0" height="100%" />
		</div>
	</div>
</block>

<block name="FOOTER">
	<script type="text/javascript">
		var page = (function(ns){
     
		    //页面初始化
		    ns.init=function(){
		        ns.query();
		    }
		    
		    //搜索事件
		    ns.query=function(){
		    	grid.load( searchs.getData() );
		    }
		    
		    //新增
		    ns.add=function(){
		    	var filter = {
		            url:"modules/activity/seckill/edit",
		            oid:"",
		            mode:1
		        }
		        $.openIframe(filter, "新增",['600px', '450px']);
		    }
		    
		    //编辑
		    ns.edit=function(){
		    	var selectedRow = grid.getSelectedRows()[0];
		        var filter = {
		            url:"modules/activity/seckill/edit",
		            oid: selectedRow.id ,
		            mode:2
		        }
		        $.openIframe(filter, "编辑",['600px', '450px']);
		    }  
		    
		  	//启用禁用
		    ns.setEnable =function(state){
		    	if( !grid.isSelected() ){
		    		return false;
		    	}
		    	$.confirm("确定" + (state == "0" ? "禁用?" : "启用?"),function(index){
		    		grid.updateField(grid.getSelectedColumnValue('id'),'is_enable',state);
			        layer.close(index);
		        });
		    }
		    
		    //删除
		    ns.del =function(){
		    	if( !grid.isSelected() ){
		    		return false;
		    	}
		    	$.confirm("确定删除？", function(index){
		    		grid.updateField(grid.getSelectedColumnValue('id'),'is_del',1);
		    		layer.close(index);
		    	});
		    }
		    
		    //商品
		    ns.goods = function(id,name,type){
		        var filter = {
		            url:"modules/activity/seckill/goods",
		            oid: id,
		            name: name,
		            type:type
		        }
		        $.openIframe(filter, name+"-商品详情",['1000px', '580px']);
		    }
		    
		    return ns;
		}({}));
		
		$(function(){ page.init();  });
	</script>
</block>